import { IThemeColor } from '../../../../type/index';
const color = ['#119dff', '#f53468'];

interface IData {
  name: string;
  value: number;
}

export const initSexScale = (echarts: any, dom: HTMLElement, dataList: IData[], themeColor: IThemeColor) => {
  const charts = echarts.init(dom);
  charts.setOption({
    //你的代码
    // backgroundColor: '#081736',
    color: color,
    title: {
      text: '男女就业比例',
      textStyle: {
        color: themeColor.font,
        fontSize: 16,
        fontWeight: 'normal',
      },
      padding: [16, 0, 0, 16],
    },
    tooltip: {
      trigger: 'item',
    },
    series: [
      {
        name: '男女比例图',
        type: 'pie',
        data: dataList,
        center: ['50%', '50%'],
        radius: ['40%', '60%'], //饼图半径
        itemStyle: {
          borderRadius: 8, //圆角
        },
        //视觉引导线
        labelLine: {
          length: 29, //第一段长度
          length2: 30, //第二段长度
          show: true,
          // color: '#00ffff',
        },
        label: {
          show: true,
          position: 'outside',
          padding: [0, -100, 0, -100],
          fontSize: 13,
          formatter: function (params: any) {
            if (params.name !== '') {
              return '{percent|' + params.name + '}\n{cir' + params.dataIndex + '|●}\n{name|' + params.value + '}';
            } else {
              return '';
            }
          },
          rich: {
            name: {
              color: themeColor.font,
              fontSize: 16,
              align: 'center',
            },
            percent: {
              fontFamily: 'DIN',
              fontWeight: 500,
              fontSize: 14,
              color: themeColor.font,
              align: 'center',
            },
            cir0: {
              fontSize: 15,
              opacity: 1,

              color: color[0],
              padding: [0, 92, 0, 92],
            },
            cir1: {
              fontSize: 15,
              opacity: 1,

              color: color[1],
              padding: [0, 92, 0, 92],
            },
          },
        },
      },
    ],
  });
};
